<template>
  <table class="table-wrap">
    <thead>
      <t-head :tHead="tHead"></t-head>
    </thead>

    <tbody>
      <t-body :tHead="tHead" :tBody="tBody" @changeValue="changeValue"></t-body>
    </tbody>
  </table>
</template>

<script setup>
import THead from './THead.vue';
import TBody from './TBody.vue';

// 定义props
const props = defineProps({
  tableData: {
    type: Object,
    defualt: () => ({
      THead: [],
      TBody: [],
    }),
  },
});

const { tHead, tBody } = props.tableData;

// const { THead, TBody } = tableData

const emits = defineEmits(['submit']);

const changeValue = function ({k:key, idx: index, value}, isHideInput) {
  console.log(key, index, value);
  emits('submit', {
    index,
    key,
    value
  }, isHideInput)
};
// index, key, value啊
</script>

<style lang="scss">
.table-wrap {
  width: 600px;
  height: 400px;
  border-collapse: collapse;
  th,
  td {
    text-align: center;
    border: 1px solid #333;
  }
}
</style>
